﻿#pragma once

#include <QWidget>
#include "ui_QtRunLog.h"

extern QString RunLogPath;

class QFile;
class StdoutRedirector;
class QtRunLog : public QWidget
{
	Q_OBJECT

public:
	QtRunLog(QWidget *parent = Q_NULLPTR);
	~QtRunLog();

	static bool DeleteOldFile(const QString dirPath, const QStringList suffix, const uint days = 7 );  //删除days之前的的日志
public slots:
	//显示日志
	void LogMessageWindowSlot(const QtMsgType type, const QString current_date_time, const QString &msg);
	//显示日志
	void LogMessageToFileSlot(const QtMsgType type, const QString current_date_time, const QString &msg);
	void readData();

private:
	Ui::QtRunLog ui;
	QFile *pLogFile = nullptr;
#ifdef ENABLEREDIRECTOR
	StdoutRedirector *redirector;
#endif
};
